#pragma once

#include "Device.h"
#include "DirectXMath.h"
#include "NeroEngine\NResource.h"

#ifdef DX_11
namespace Graphics
{
enum BufferType
{
	VertexBuffer = 1,
	IndexBuffer = 2,
	ConstantBuffer = 4,
	ShaderResourceBuffer = 8,
	StreamOutputBuffer = 16,
	RenderTargetBuffer = 32,
	DepthStencilBuffer = 64,
	UnorderedAccessBuffer = 128
};

class Buffer : public Engine::NResource
{
	RTTI_DECLARATIONS(Buffer, Engine::NResource)
public:
	Buffer(void);

	~Buffer(void);

	bool Initialize(unsigned int vertexSize, void* vertices, UINT NumberOfVerts, BufferType bufferType);

	bool Initialize(D3D11_BUFFER_DESC bufferDesc);

	bool Initialize(D3D11_BUFFER_DESC bufferDesc, D3D11_SUBRESOURCE_DATA  data);

	void Render(unsigned int stride, unsigned int offset);

	void Lock();

	void Unlock();

	void Release();

	ID3D11Buffer* GetResource(){return mBuffer;}

private:
	ID3D11Buffer* mBuffer;
	unsigned int mNumberOfVerts;
	BufferType mBufferType;
};
}

#elif defined( DX_9 )
namespace Graphics
{
struct CUSTOMVERTEX
{
	float x,y,z;
	DWORD color;
};

class Buffer
{
public:
	Buffer(void);

	~Buffer(void);

	void Initialize(LPDIRECT3DDEVICE9 device, UINT NumberOfVerts);

	void Render(LPDIRECT3DDEVICE9 device);

	void Lock();

	void Unlock();

	VOID* GetMemoryPointer();

private:
	LPDIRECT3DVERTEXBUFFER9 mVertexBuffer;
	VOID* mMemoryPointer;
	unsigned int mNumberOfVerts;
};
}
#endif